#!/usr/bin/perl

use Modern::Perl;
use Test::More tests => 1;
use File::Slurp;
use Log::Log4perl qw( :easy );

require AEF::MEFProcessor;
require AEF::AEFReader;

Log::Log4perl->easy_init($INFO);

my $processor = AEF::MEFProcessor->new(moduleName => 'Main');

my $file = "./t/AEF_test_files/ConsoleApp.AEF";
my $data = read_file($file, binmode => ':raw');

my $aef = AEF::AEFReader->new(processor => $processor);
$aef->ReadAEF($data);

my @chars = unpack('C*', $processor->mefData);
my @expected = (1, 0, 27, 0, 0, 0, 128, 2, 67, 65, 45, 86, 79, 32, 77, 111, 100, 117,
	108, 101, 32, 69, 120, 112, 111, 114, 116, 32, 70, 105, 108, 101, 0,
	32, 0, 5, 0, 0, 0, 77, 97, 105, 110, 0, 14, 1, 56, 0, 0, 0, 2, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 65, 4, 70, 53, 161, 17,
	128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 6, 0, 0, 0, 83, 84, 65, 82,
	84, 0, 81, 0, 2, 0, 0, 0, 2, 0, 68, 0, 2, 0, 0, 0, 3, 0, 77, 0, 2, 0,
	0, 0, 17, 0, 65, 0, 55, 2, 0, 0, 102, 117, 110, 99, 116, 105, 111,
	110, 32, 83, 116, 97, 114, 116, 40, 112, 41, 13, 10, 32, 32, 108, 111,
	99, 97, 108, 32, 115, 67, 109, 100, 76, 105, 110, 101, 32, 58, 61, 32,
	80, 115, 122, 50, 83, 116, 114, 105, 110, 103, 40, 95, 71, 101, 116,
	67, 109, 100, 76, 105, 110, 101, 40, 41, 41, 32, 97, 115, 32, 115,
	116, 114, 105, 110, 103, 13, 10, 32, 32, 108, 111, 99, 97, 108, 32,
	111, 67, 111, 110, 32, 97, 115, 32, 67, 111, 110, 115, 111, 108, 101,
	13, 10, 32, 32, 108, 111, 99, 97, 108, 32, 115, 73, 110, 112, 117,
	116, 32, 97, 115, 32, 115, 116, 114, 105, 110, 103, 13, 10, 13, 10,
	32, 32, 111, 67, 111, 110, 32, 58, 61, 32, 67, 111, 110, 115, 111,
	108, 101, 123, 125, 13, 10, 13, 10, 32, 32, 111, 67, 111, 110, 58, 67,
	108, 101, 97, 114, 40, 41, 13, 10, 32, 32, 111, 67, 111, 110, 58, 84,
	105, 116, 108, 101, 32, 58, 61, 32, 34, 86, 105, 115, 117, 97, 108,
	32, 79, 98, 106, 101, 99, 116, 115, 32, 67, 111, 110, 115, 111, 108,
	101, 32, 65, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 46, 34,
	13, 10, 32, 32, 111, 67, 111, 110, 58, 87, 114, 105, 116, 101, 76,
	105, 110, 101, 40, 34, 67, 65, 45, 86, 105, 115, 117, 97, 108, 32, 79,
	98, 106, 101, 99, 116, 115, 32, 66, 97, 115, 105, 99, 32, 67, 111,
	110, 115, 111, 108, 101, 32, 65, 112, 112, 108, 105, 99, 97, 116, 105,
	111, 110, 46, 34, 41, 13, 10, 32, 32, 111, 67, 111, 110, 58, 87, 114,
	105, 116, 101, 40, 34, 67, 97, 108, 108, 101, 100, 32, 119, 105, 116,
	104, 32, 99, 111, 109, 109, 97, 110, 100, 32, 108, 105, 110, 101, 58,
	32, 34, 41, 13, 10, 32, 32, 111, 67, 111, 110, 58, 84, 101, 120, 116,
	65, 116, 116, 114, 105, 98, 117, 116, 101, 32, 58, 61, 32, 95, 79,
	114, 40, 70, 79, 82, 69, 71, 82, 79, 85, 78, 68, 95, 82, 69, 68, 44,
	32, 70, 79, 82, 69, 71, 82, 79, 85, 78, 68, 95, 73, 78, 84, 69, 78,
	83, 73, 84, 89, 41, 13, 10, 32, 32, 111, 67, 111, 110, 58, 87, 114,
	105, 116, 101, 76, 105, 110, 101, 40, 115, 67, 109, 100, 76, 105, 110,
	101, 41, 13, 10, 32, 32, 111, 67, 111, 110, 58, 84, 101, 120, 116, 65,
	116, 116, 114, 105, 98, 117, 116, 101, 32, 58, 61, 32, 70, 79, 82, 69,
	71, 82, 79, 85, 78, 68, 95, 87, 72, 73, 84, 69, 13, 10, 32, 32, 111,
	67, 111, 110, 58, 87, 114, 105, 116, 101, 40, 34, 69, 110, 116, 101,
	114, 32, 116, 101, 120, 116, 58, 32, 34, 41, 13, 10, 32, 32, 115, 73,
	110, 112, 117, 116, 32, 58, 61, 32, 111, 67, 111, 110, 58, 82, 101,
	97, 100, 40, 41, 13, 10, 32, 32, 111, 67, 111, 110, 58, 87, 114, 105,
	116, 101, 40, 34, 89, 111, 117, 32, 101, 110, 116, 101, 114, 101, 100,
	32, 58, 32, 34, 32, 43, 32, 115, 73, 110, 112, 117, 116, 41, 13, 10,
	0, 78, 0, 18, 0, 0, 0, 102, 117, 110, 99, 116, 105, 111, 110, 32, 83,
	116, 97, 114, 116, 40, 112, 41, 0, 156, 0, 2, 0, 0, 0, 1, 0, 132, 0,
	60, 0, 0, 0, 1, 0, 0, 0, 172, 4, 0, 0, 19, 0, 0, 0, 12, 0, 0, 0, 64,
	64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 144, 0, 2,
	0, 0, 0, 1, 0, 145, 0, 6, 0, 0, 0, 4, 0, 0, 0, 80, 0, 35, 1, 6, 0, 0,
	0, 83, 116, 97, 114, 116, 0, 13, 1, 84, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
	0, 1, 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 105,
	4, 70, 53, 165, 102, 36, 55, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0);

is_deeply(\@chars, \@expected, "Check contents same");

